Error while compiling with new RR scheduler
Hi,
Please find attached the source code of Round Robin scheduler which I am trying to add to Xen 3.3.1.
I am facing the following error messages while compiling the same.
sched_rrobin.c:31: error: two or more data types in declaration specifiers
sched_rrobin.c: In function ‘rrobin_vcpu_init’:
sched_rrobin.c:34: error: incompatible types in return
sched_rrobin.c:51: error: incompatible types in return
sched_rrobin.c:94: error: initialization from incompatible pointer type
I believe the error in line 94 is causing the rest of the error messages. I have checked with the structure definition in sched-if.h as well as the implementation of the same in other schedulers such as SEDF and Credit.
Request you to kindly provide your feedback regarding the same.
Thanks & Regards
Ananth
#include <xen/lib.h>
#include <xen/sched.h>
#include <xen/time.h>
#include <xen/sched-if.h>
#include <xen/softirq.h>
#include <xen/errno.h>
#include <xen/list.h>
#include <xen/timer.h>
#define EDOM_INFO(d) ((struct rrobin_vcpu_info *)((d)->sched_priv))
#define CPU_INFO(cpu) \
((struct rrobin_cpu_info *)per_cpu(schedule_data, cpu).sched_priv)
#define RUNQ(cpu) (&CPU_INFO(cpu)->runnableq)
struct list_head *vcpu_list_head;
struct list_head *head;
struct list_head *vcpu_list_tail;
/*struct list_head *runq = RUNQ(cpu);*/
struct rrobin_vcpu_info *runq;
struct rrobin_vcpu_info {
struct list_head list;
struct vcpu *vcpu;
};struct rrobin_cpu_info {
struct list_head runnableq;
}/* Add a VCPU */
static int rrobin_vcpu_init(struct vcpu *v){
struct rrobin_vcpu_info *inf;
if ( (v->sched_priv = xmalloc(struct rrobin_vcpu_info)) == NULL )
return 1;
memset(v->sched_priv, 0, sizeof(struct rrobin_vcpu_info));
inf = EDOM_INFO(v);
inf->vcpu = v;
/* Allocate per-CPU context if this is the first domain to be added. */
if ( unlikely(per_cpu(schedule_data, v->processor).sched_priv == NULL) )
{
per_cpu(schedule_data, v->processor).sched_priv =
xmalloc(struct rrobin_cpu_info);
BUG_ON(per_cpu(schedule_data, v->processor).sched_priv == NULL);
memset(CPU_INFO(v->processor), 0, sizeof(*CPU_INFO(v->processor)));
INIT_LIST_HEAD(RUNQ(v->processor));
}
INIT_LIST_HEAD(&(inf->list));
return 0;
}static void rrobin_vcpu_destroy(struct vcpu *v)
{
xfree(v->sched_priv);
}static inline void increment_run_queue(void){
vcpu_list_head = &(runq->list);
vcpu_list_tail = (vcpu_list_head)->prev;
head = vcpu_list_head;
vcpu_list_tail = vcpu_list_head;
vcpu_list_head = (vcpu_list_tail)->next;
vcpu_list_tail = head;
}struct task_slice rrobin_schedule(s_time_t now){
int cpu = smp_processor_id();
/*struct rrobin_vcpu_info *inf = EDOM_INFO(current);*/
struct rrobin_vcpu_info *runinf;
struct task_slice ret;
ret.time = MILLISECS(10); /* Time quantum to scan the VCPU list to find a runnable VCPU */
runq->list = RUNQ(cpu);
if ( !list_empty(&(runq->list)) ){
runinf = list_entry((&(runq->list))->next,struct rrobin_vcpu_info,list);
ret.task = runinf->vcpu;}
increment_run_queue();
return ret;
}
struct scheduler sched_rrobin_def = {
.name = "Round robin Scheduler",
.opt_name = "rrobin",
.sched_id = XEN_SCHEDULER_SEDF, .init_vcpu = rrobin_vcpu_init,
.destroy_vcpu = rrobin_vcpu_destroy,
.do_schedule = rrobin_schedule,
};
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Hi,
I figured out that the error was because of a missing ' ; ' . This has been fixed now. I have attached the modified code.
While compiling I am getting the below error message.
cc1: warnings being treated as errorssched_rrobin.c: In function ‘rrobin_schedule’:
sched_rrobin.c:74: error: ‘ret.task’ may be used uninitialized in this function
Please guide.
Thanks & Regards
Ananth
---------- Forwarded message ----------
From: Ananth <[email protected]>
Date: Fri, Apr 24, 2009 at 7:25 PM
Subject: Error while compiling with new RR scheduler
To: "[email protected]" <[email protected]>
Hi,
Please find attached the source code of Round Robin scheduler which I am trying to add to Xen 3.3.1.
I am facing the following error messages while compiling the same.
sched_rrobin.c:31: error: two or more data types in declaration specifiers
sched_rrobin.c: In function ‘rrobin_vcpu_init’:
sched_rrobin.c:34: error: incompatible types in return
sched_rrobin.c:51: error: incompatible types in return
sched_rrobin.c:94: error: initialization from incompatible pointer type
I believe the error in line 94 is causing the rest of the error messages. I have checked with the structure definition in sched-if.h as well as the implementation of the same in other schedulers such as SEDF and Credit.
Request you to kindly provide your feedback regarding the same.
Thanks & Regards
Ananth
#include <xen/lib.h>
#include <xen/sched.h>
#include <xen/time.h>
#include <xen/sched-if.h>
#include <xen/softirq.h>
#include <xen/errno.h>
#include <xen/list.h>
#include <xen/timer.h>
#define EDOM_INFO(d) ((struct rrobin_vcpu_info *)((d)->sched_priv))
#define CPU_INFO(cpu) \
((struct rrobin_cpu_info *)per_cpu(schedule_data, cpu).sched_priv)
#define RUNQ(cpu) (&CPU_INFO(cpu)->runnableq)
struct list_head *vcpu_list_head;
struct list_head *head;
struct list_head *vcpu_list_tail;
/*struct list_head *runq = RUNQ(cpu);*/
struct list_head *runq;
struct rrobin_vcpu_info {
struct list_head list;
struct vcpu *vcpu;
};struct rrobin_cpu_info {
struct list_head runnableq;
};/* Add a VCPU */
static int rrobin_vcpu_init(struct vcpu *v){
struct rrobin_vcpu_info *inf;
if ( (v->sched_priv = xmalloc(struct rrobin_vcpu_info)) == NULL )
return 1;
memset(v->sched_priv, 0, sizeof(struct rrobin_vcpu_info));
inf = EDOM_INFO(v);
inf->vcpu = v;
/* Allocate per-CPU context if this is the first domain to be added. */
if ( unlikely(per_cpu(schedule_data, v->processor).sched_priv == NULL) )
{
per_cpu(schedule_data, v->processor).sched_priv =
xmalloc(struct rrobin_cpu_info);
BUG_ON(per_cpu(schedule_data, v->processor).sched_priv == NULL);
memset(CPU_INFO(v->processor), 0, sizeof(*CPU_INFO(v->processor)));
INIT_LIST_HEAD(RUNQ(v->processor));
}
INIT_LIST_HEAD(&(inf->list));
return 0;
}static void rrobin_vcpu_destroy(struct vcpu *v)
{
xfree(v->sched_priv);
}static inline void increment_run_queue(void){
vcpu_list_head = runq;
vcpu_list_tail = (vcpu_list_head)->prev;
head = vcpu_list_head;
vcpu_list_tail = vcpu_list_head;
vcpu_list_head = (vcpu_list_tail)->next;
vcpu_list_tail = head;
}struct task_slice rrobin_schedule(s_time_t now){
/*struct list_head temp; */
int cpu = smp_processor_id();
/*struct rrobin_vcpu_info *inf = EDOM_INFO(current);*/
struct rrobin_vcpu_info *runinf;
struct vcpu *temp;
struct task_slice ret;
ret.time = MILLISECS(10); /* Time quantum to scan the VCPU list to find a runnable VCPU */
runq = RUNQ(cpu);
if ( !list_empty(runq) ){
runinf = list_entry(runq->next,struct rrobin_vcpu_info,list);
temp = runinf->vcpu;
ret.task = temp;
}increment_run_queue();
return ret;
}
struct scheduler sched_rrobin_def = {
.name = "Round robin Scheduler",
.opt_name = "rrobin",
.sched_id = XEN_SCHEDULER_SEDF, .init_vcpu = rrobin_vcpu_init,
.destroy_vcpu = rrobin_vcpu_destroy,
.do_schedule = rrobin_schedule,
};
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
The message says it pretty clearly: you return the value of ret, but there are control paths in the function for which ret.task is not set.
Namely, if list_empty(runq) is true, then you will return an
uninitialized value, which may be anything (garbage on the stack, NULL, &c). This will most likely cause Xen to crash, as xen/common/schedule.c assumes that ret.task will be a valid, non-NULL pointer.
If you happen to know that runq is never empty, then you don't need the if statement. If it may be empty, then you need an else clause to return the idle vcpu for that processor.
-George
2009/4/24 Ananth <[email protected]>:
Quoted 49 lines
Hi,
I figured out that the error was because of a missing ' ; ' . This has been fixed now. I have attached the modified code. While compiling I am getting the below error message.cc1: warnings being treated as errors
sched_rrobin.c: In function ‘rrobin_schedule’:
sched_rrobin.c:74: error: ‘ret.task’ may be used uninitialized in this functionPlease guide.
Thanks & Regards
Ananth---------- Forwarded message ----------
From: Ananth <[email protected]>
Date: Fri, Apr 24, 2009 at 7:25 PM
Subject: Error while compiling with new RR scheduler
To: "[email protected]" <[email protected]>Hi,
Please find attached the source code of Round Robin scheduler which I am trying to add to Xen 3.3.1. I am facing the following error messages while compiling the same.sched_rrobin.c:31: error: two or more data types in declaration specifiers
sched_rrobin.c: In function ‘rrobin_vcpu_init’:sched_rrobin.c:34: error: incompatible types in return
sched_rrobin.c:51: error: incompatible types in return
sched_rrobin.c:94: error: initialization from incompatible pointer type
I believe the error in line 94 is causing the rest of the error messages. I have checked with the structure definition in
sched-if.has well as the implementation of the same in other schedulers such as SEDF and Credit.Request you to kindly provide your feedback regarding the same.
Thanks & Regards
Ananth_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Hello,
Thank you so much for pointing it out. How could I miss something so obvious. I am able to compile it now. I will get back to you in case I get into any issues during run time.
Thank you.
Regards
Ananth
Quoted 50 lines · George Dunlap
The message says it pretty clearly: you return the value of ret, but there are control paths in the function for which ret.task is not set.
Namely, iflist_empty(runq)is true, then you will return an
uninitialized value, which may be anything (garbage on the stack, NULL, &c). This will most likely cause Xen to crash, asxen/common/schedule.cassumes that ret.task will be a valid, non-NULL pointer.If you happen to know that runq is never empty, then you don't need the if statement. If it may be empty, then you need an else clause to return the idle vcpu for that processor.
-George
2009/4/24 Ananth <[email protected]>:
Quoted 2 lines
Hi,
I figured out that the error was because of a missing ' ; ' . This hasbeen fixed now. I have attached the modified code.
Quoted 5 lines
While compiling I am getting the below error message.
cc1: warnings being treated as errors
sched_rrobin.c: In function ‘rrobin_schedule’:
sched_rrobin.c:74: error: ‘ret.task’ may be used uninitialized in thisfunction
Quoted 14 lines
Please guide.
Thanks & Regards
Ananth---------- Forwarded message ----------
From: Ananth <[email protected]>
Date: Fri, Apr 24, 2009 at 7:25 PM
Subject: Error while compiling with new RR scheduler
To: "[email protected]" <[email protected]>Quoted 2 lines
Hi,
Please find attached the source code of Round Robin scheduler which I amtrying to add to Xen 3.3.1.
Quoted 3 lines
I am facing the following error messages while compiling the same.
sched_rrobin.c:31: error: two or more data types in declaration
specifiers
Quoted 5 lines
sched_rrobin.c: In function ‘rrobin_vcpu_init’:sched_rrobin.c:34: error: incompatible types in return
Quoted 21 lines
Quoted 5 lines
sched_rrobin.c:51: error: incompatible types in return
sched_rrobin.c:94: error: initialization from incompatible pointer type
I believe the error in line 94 is causing the rest of the error messages.
I have checked with the structure definition in
sched-if.has well as the implementation of the same in other schedulers such as SEDF and Credit.Quoted 13 lines
Request you to kindly provide your feedback regarding the same.
Thanks & Regards
Ananth_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel